Skip to content

chore(lint): exclude goconst from test files - #55

Closed
bfirestone wants to merge 1 commit into
mainfrom
chore/exclude-goconst-from-tests
Closed

chore(lint): exclude goconst from test files#55
bfirestone wants to merge 1 commit into
mainfrom
chore/exclude-goconst-from-tests

Conversation

@bfirestone

Copy link
Copy Markdown
Contributor

What

Adds a goconst exclusion for _test.go files in .golangci.yaml, placed alongside the existing dupl exclusion.

- linters:
    - goconst # Repeated string detection
  path: _test\.go # Test fixtures repeat literals by design (DAMP > DRY)

Why

Test fixtures intentionally repeat literals (status strings, IDs, transcript paths) as self-contained sample data — DAMP (Descriptive And Meaningful Phrases) over DRY. Hoisting fixture strings into constants forces readers to jump away from a test to learn what a row contains, and there's no single-source-of-truth payoff the way there is for production logic — which is what goconst is actually for.

This mirrors the decision already made for the dupl linter, which is excluded from _test.go with the comment "Test files often have similar structures for readability." goconst is the same category of duplication-in-tests-is-fine.

Newer golangci-lint versions (≥ v2.12) surface goconst on test files (~50 hits across internal/types, internal/storage/sqlite, internal/client test fixtures); this keeps that noise out consistently, independent of linter version.

Scope

Config-only change. No production code or tests modified. Where a test literal genuinely mirrors a production domain constant (e.g. a status value), referencing the existing types constant is still encouraged — that's drift protection, not covered here.

Test fixtures intentionally repeat literals (status strings, IDs, paths)
as self-contained sample data — DAMP (Descriptive And Meaningful Phrases)
over DRY. Extracting them into constants hurts test readability without
the single-source-of-truth payoff that goconst targets in production code.

This mirrors the existing dupl exclusion for _test.go ("Test files often
have similar structures for readability"). Newer golangci-lint versions
surface goconst on test files; this keeps that noise out consistently.
@bfirestone

Copy link
Copy Markdown
Contributor Author

Superseded by #54, which already added a goconst exclusion for test files in .golangci.yaml (and bumped CI to golangci-lint v2.12.2 with tree-wide fixes). This change is now redundant. Closing.

@bfirestone bfirestone closed this Jun 8, 2026
@bfirestone
bfirestone deleted the chore/exclude-goconst-from-tests branch June 8, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant